<%@ page language="java" pageEncoding="UTF-8"%>
<%String path = request.getContextPath();%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script type="text/javascript">
function changeInputFileValue(obj) {
	var filePath = obj.value;
	var filename = filePath.replace(/.*(\/|\\)/, "");
	var fileExt=(/[.]/.exec(filename)) ? /[^.]+$/.exec(filename.toUpperCase()) : "";
	if (fileExt == "" || !/^JPG|JPEG|GIF|BMP|PNG$/.test(fileExt)) { 
		alert("只允许上传jpg、jpeg、gif、bmp、png格式的文件！\n\n         请重新选择图片上传！");
		var inpObj = '<input name="uploadObj" type="file" value="浏览" onchange="changeInputFileValue(this);"/>';
		$(obj).replaceWith($(inpObj));
		$("#uri_inp_file").text("");
		$("#upload_file_button").attr("disabled", true);
	} else {
		$("#uri_inp_file").text(filePath);
		$("#upload_file_button").attr("disabled", false);
	}
}
function processUploadResult(args) {
	if(args["exists"]){
		$("#uri_inp_file").text("");
		$("#upload_file_button").attr("disabled", true);
		alert("请不要添加相同像素的图片！");
		var inpObj = '<input name="uploadObj" type="file" value="浏览" onchange="changeInputFileValue(this);"/>';
		$("input[name='uploadObj']").replaceWith($(inpObj));
	}else{
		parent.confirmAddPicContent(args);
		$.pdialog.closeCurrent();
	}
}
</script>
</head>
<h2 class="contentTitle">请选择需要上传的图片</h2>
<form action="<%=path%>/upload/uploadAdertisingImg.action" method="post" enctype="multipart/form-data" class="pageForm" onsubmit="return iframeCallback(this, processUploadResult);">
<input type="hidden" name="uuid" value="${param.uuid}"/>
<input type="hidden" name="pixels" value="${param.pixels}"/>
<input type="hidden" name="pIndex" value="${param.pIndex}"/>
<div class="pageContent">
	<div class="pageFormContent" layoutH="97">
		<div style="height: 65px;width: 400px;text-align: center"><label id="uri_inp_file" style="width: 530px"></label></div>
		<div style="width: 300px;margin-left: 75px"><input name="uploadObj" type="file" value="浏览" onchange="changeInputFileValue(this);"/></div>
	</div>
	<div class="formBar">
		<ul>
			<li><div class="buttonActive"><div class="buttonContent"><button id="upload_file_button" type="submit" disabled="disabled">上传</button></div></div></li>
			<li><div class="button"><div class="buttonContent"><button class="close" type="button">关闭</button></div></div></li>
		</ul>
	</div>
</div>
</form>